using UnityEngine;
using System.Collections;

public class SplashScript : MonoBehaviour {
	
	// Use this for initialization
	void Start () {
		ArrayList eggs = ((Builder)GameObject.Find("Builder").GetComponent<Builder>()).getEggs();
		ArrayList eggsToKill = new ArrayList();
		foreach(GameObject egg in eggs){
			if(Vector3.Distance(egg.transform.position, gameObject.transform.position) < 15){
				eggsToKill.Add(egg);
			}
		}
		foreach(GameObject egg in eggsToKill){
			killEgg(egg);
		}
		Destroy(gameObject);
	}
	
	private void killEgg(GameObject obj){
		((Builder)GameObject.Find("Builder").GetComponent("Builder")).removeEgg(obj);
		Destroy(obj);
	}
	
}
